Button Customization

Override the Save Button Handler to Modify and Redirect URL Values

Description
Shows how to modify URL by overriding save button click event handler.
Variables
Button Control
Select the Save button on the page
Applies to
P_Button Control class
Code
 
''' 
''' This is the Event handler for Save Button. Add your code to customize save button behavior.
''' 
Public Overrides Sub ${Button Control}_Click(ByVal sender As Object, ByVal args As EventArgs)

       ' Please remove the above code: SaveButton_Click_Base(sender, args) for this customization to run successfully.. 
       
	   ' Define the URL of a page to which you want to redirect after saving the record.  
       Dim url As String = "../OtherPages/SomeOtherPage.aspx?Param1=1"
       Dim shouldRedirect As Boolean = true
       Try
			
			' Start Transaction and save record
			DbUtils.StartTransaction()					 
			Me.SaveData()
           
		   ' Modify the URL to redirect to Show page
           url = Me.ModifyRedirectUrl(url, "")

           Me.CommitTransaction(sender)
		   
       Catch ex As Exception
           shouldRedirect = false  
		   'If there is an Exception then display an alert message
           BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
           Me.RollBackTransaction(sender)     
       Finally
		   ' End Transaction
           DbUtils.EndTransaction()     
       End Try
       If shouldRedirect Then
           Me.ShouldSaveControlsToSession = true
           Me.Page.Response.Redirect(url)
        End If       
		
End Sub

 

Terms of Service Privacy Statement